package net.sxnic.normal.action;

import javax.annotation.Resource;

import net.sxnic.comm.CommConstant;
import net.sxnic.comm.basecode.BaseCodeManager;
import net.sxnic.comm.property.PropertyManager;
import net.sxnic.ugr.UgrActionSupport;
import net.sxnic.ugr.UgrConstant;
import net.sxnic.ugr.dept.DeptManager;
import net.sxnic.ugr.group.GroupManager;
import net.sxnic.ugr.menu.MenuManager;
import net.sxnic.ugr.permission.PermissionManager;
import net.sxnic.ugr.resource.ResourceManager;
import net.sxnic.ugr.role.RoleManager;
import net.sxnic.ugr.security.AuthorizationManager;
import net.sxnic.ugr.user.UserManager;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * 系统变量重新载入
 * 
 * @author yfsun
 * 
 */
public class SystemRefresh extends UgrActionSupport {

	private static Log log = LogFactory.getLog(SystemRefresh.class);

	@Resource
	private UserManager userManager;
	@Autowired
	private AuthorizationManager authorizationManager;
	@Autowired
	private BaseCodeManager basecodeManager;
	@Autowired
	private PropertyManager propertyManager;
	@Autowired
	private MenuManager menuManager;
	@Autowired
	private GroupManager groupManager;

	@Autowired
	private DeptManager deptManager;

	@Autowired
	private PermissionManager permissionManager;

	@Autowired
	private ResourceManager resourceManager;

	@Autowired
	private RoleManager roleManager;

	public String execute() {
		// 基本码表map初始化
		CommConstant.BASECODE_MAP = basecodeManager.init();

		// 基本码表map初始化
		CommConstant.MENU_MAP = menuManager.findMap1();

		// 属性表map初始化
		CommConstant.PROPERTY_MAP = propertyManager.init();

		// 部门Map初始化
		UgrConstant.DEPT_MAP = deptManager.findMap();

		// 用户Map初始化
		UgrConstant.USER_MAP = userManager.findUserMap();

		UgrConstant.USER_ORDER_MAP = userManager.findUserOrderMap();
		
		//addActionMessage("刷新成功！");
		
		log.debug("=========系统变量重载入成功============");
		
		return SUCCESS;
	}
}
